import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, DateTime
from sqlalchemy.orm import sessionmaker

engine = sa.create_engine('clickhouse://admin:123456@192.168.56.10:8123/picture_info', echo=True)

Session = sessionmaker(bind=engine)
# 创建Session类实例
session = Session()

Base = declarative_base()

class Picture_Info(Base):
    __tablename__ = 'picture_info'
    id = Column(Integer, primary_key=True, autoincrement=True)
    file_name = Column(String(200), nullable=False, index=True)
    file_md5 = Column(String(200), nullable=False, index=True)
    upload_time = Column(DateTime, nullable=False, index=True)

if __name__ == '__main__':
    pic = Picture_Info(Base)
    # 创建链接
    # 创建 Person 表
    pic.__table__.create(engine, checkfirst=True)
    # 创建Session类对象
    Session = sessionmaker(bind=engine)
    # 创建Session类实例
    session = Session()
